﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
    
<UserControl x:Class="System.Windows.Controls.Samples.DataFormTemplateSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples">
    <StackPanel>
        <ContentControl Content="Template-driven DataForm" Style="{StaticResource Header}" />
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0">
                <CheckBox Content="AutoCommit" IsChecked="{Binding AutoCommit, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
                <CheckBox Content="AutoEdit" IsChecked="{Binding AutoEdit, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
                <TextBlock Text="CommandButtonsVisibility" Style="{StaticResource ApiName}" Margin="4" />
                <ComboBox SelectedItem="{Binding CommandButtonsVisibility, ElementName=dataForm, Mode=TwoWay}" SelectedIndex="0" Margin="4">
                    <sys:String>All</sys:String>
                    <sys:String>Add</sys:String>
                    <sys:String>Delete</sys:String>
                    <sys:String>Edit</sys:String>
                    <sys:String>Navigation</sys:String>
                    <sys:String>None</sys:String>
                </ComboBox>
                <CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
            </StackPanel>
            <dataform:DataForm x:Name="dataForm" ItemsSource="{Binding}" HorizontalAlignment="Left" MinWidth="400" MaxWidth="500" Margin="4" Grid.Column="1">
                <dataform:DataForm.EditTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <dataform:DataField>
                                <TextBox Text="{Binding FirstName, Mode=TwoWay}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding Email, Mode=TwoWay}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding Phone, Mode=TwoWay}" />
                            </dataform:DataField>
                            <dataform:DataField Label="Calendar">
                                <controls:Calendar></controls:Calendar>
                            </dataform:DataField>
                        </StackPanel>
                    </DataTemplate>
                </dataform:DataForm.EditTemplate>
            </dataform:DataForm>
        </Grid>
        <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="DataFormTemplateSample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;
    
&lt;UserControl x:Class="System.Windows.Controls.Samples.DataFormTemplateSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:samples="clr-namespace:System.Windows.Controls.Samples"&gt;
    &lt;StackPanel&gt;
        &lt;ContentControl Content="Template-driven DataForm" Style="{StaticResource Header}" /&gt;
        &lt;Grid&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="Auto" /&gt;
                &lt;ColumnDefinition /&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            &lt;StackPanel Grid.Column="0"&gt;
                &lt;CheckBox Content="AutoCommit" IsChecked="{Binding AutoCommit, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
                &lt;CheckBox Content="AutoEdit" IsChecked="{Binding AutoEdit, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
                &lt;TextBlock Text="CommandButtonsVisibility" Style="{StaticResource ApiName}" Margin="4" /&gt;
                &lt;ComboBox SelectedItem="{Binding CommandButtonsVisibility, ElementName=dataForm, Mode=TwoWay}" SelectedIndex="0" Margin="4"&gt;
                    &lt;sys:String&gt;All&lt;/sys:String&gt;
                    &lt;sys:String&gt;Add&lt;/sys:String&gt;
                    &lt;sys:String&gt;Delete&lt;/sys:String&gt;
                    &lt;sys:String&gt;Edit&lt;/sys:String&gt;
                    &lt;sys:String&gt;Navigation&lt;/sys:String&gt;
                    &lt;sys:String&gt;None&lt;/sys:String&gt;
                &lt;/ComboBox&gt;
                &lt;CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
            &lt;/StackPanel&gt;
            &lt;dataform:DataForm x:Name="dataForm" ItemsSource="{Binding}" HorizontalAlignment="Left" MinWidth="400" MaxWidth="500" Margin="4" Grid.Column="1"&gt;
                &lt;dataform:DataForm.EditTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;StackPanel&gt;
                            &lt;dataform:DataField&gt;
                                &lt;TextBox Text="{Binding FirstName, Mode=TwoWay}" /&gt;
                            &lt;/dataform:DataField&gt;
                            &lt;dataform:DataField&gt;
                                &lt;TextBox Text="{Binding Email, Mode=TwoWay}" /&gt;
                            &lt;/dataform:DataField&gt;
                            &lt;dataform:DataField&gt;
                                &lt;TextBox Text="{Binding Phone, Mode=TwoWay}" /&gt;
                            &lt;/dataform:DataField&gt;
                            &lt;dataform:DataField Label="Calendar"&gt;
                                &lt;controls:Calendar&gt;&lt;/controls:Calendar&gt;
                            &lt;/dataform:DataField&gt;
                        &lt;/StackPanel&gt;
                    &lt;/DataTemplate&gt;
                &lt;/dataform:DataForm.EditTemplate&gt;
            &lt;/dataform:DataForm&gt;
        &lt;/Grid&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="DataFormTemplateSample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.ComponentModel;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample page demonstrating the DataForm with templates.
    /// &lt;/summary&gt;
    [Sample("Template-driven DataForm", DifficultyLevel.Intermediate)]
    [Category("DataForm")]
    public partial class DataFormTemplateSample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a DataFormTemplateSample.
        /// &lt;/summary&gt;
        public DataFormTemplateSample()
        {
            InitializeComponent();
            DataContext = Contact.People;
        }
    }
}
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="DataFormTemplateSample.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports System.Collections.ObjectModel
Imports System.ComponentModel

''' &lt;summary&gt;
''' Sample page demonstrating the DataForm with templates.
''' &lt;/summary&gt;
&lt;Sample("Template-driven DataForm", DifficultyLevel.Intermediate)&gt; _
&lt;Category("DataForm")&gt; _
Partial Public Class DataFormTemplateSample
    Inherits UserControl

    ''' &lt;summary&gt;
    ''' Initializes a DataFormTemplateSample.
    ''' &lt;/summary&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification:="InitializeComponent Required by Visual Studio.")&gt; _
    Public Sub New()
        InitializeComponent()
        DataContext = Contact.People
    End Sub
End Class</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
    </StackPanel>
</UserControl>